extends mixins/_layout

block content
  link(href="/css/bootstrap.min.css", rel="stylesheet")
  
  body
    #wrapper
      //- 顶部导航
      include mixins/_header
      +header(navigator, 'post')
      
      #post
        p.title
          span 你的文章
          span 预览
        textarea#textInput(oninput="this.editor.update()")
        #preview

      include mixins/_post
      +post(cateslist)

      include mixins/_footer
      +footer

    include mixins/_footer_js
    +footerjs(config)
    script(src="/js/markdown" +config.min + ".js")
    script(src="/js/laydate" +config.min + ".js")
    script.
      window.addEventListener('DOMContentLoaded',function(){
        function Editor(input, preview) {
          this.update = function () {
            preview.innerHTML = markdown.toHTML(input.value);
          };
          input.editor = this;
          this.update();
        }
        new Editor($("#textInput"), $("#preview"));

        // 防止误操作页面刷新/关闭
        window.onbeforeunload=function(){
          return false;
        }
        //提交表单
        kblog.postArticle();
        if($('#cateslist')){
          kblog.toggleCases();
        };

        var dateInput=$('#date'), time = new Date(), year = time.getFullYear(), month = time.getMonth()+1, date = time.getDate();
        month = month<10? ('0'+month) : month;
        date = date<10? ('0'+date) : date;
        dateInput.value=year + '-' + month + '-' + date;
      }, false);